#!/usr/bin/env python

Hotkeys = {
    "Quit": (pygame.K_ESCAPE,),
    "Menu": (pygame.K_MENU,),
    "Left": (pygame.K_LEFT,),
    "Right": (pygame.K_RIGHT,),
    "Up": (pygame.K_UP,),
    "Down": (pygame.K_DOWN,),
    "Shift": (pygame.K_LSHIFT, pygame.K_RSHIFT,),
    "Reset View": (pygame.K_r,)
}

KeyStatus = {
    "Left": False,
    "Right": False,
    "Up": False,
    "Down": False,
    "Shift": False,
}

class EventType(object):
    def __init__(self, name, category):
        self.name = name
        self.category = category

class EventSystem(object):
    def __init__(self):
        self.Eventa = dict()
        self.EventTypes = list()

    def AddEvent(eventTypes):
        """Decorator for adding event callables."""
        def WrapEvent(f):
            def WrappedEvent(*args):
                f(*args)
            WrappedEvent.__name__ = f.__name__
            return WrappedEvent
        return WrapEvent

    def ProcessEvents(self):
        self.EventQueue.insert(1, pygame.event.get())
        for event in self.EventQueue:
            if event.type == pygame.VIDEORESIZE:
                resize(event.w, event.h)
            elif event.type == pygame.QUIT:
                quit()
            elif event.type == pygame.KEYDOWN:
                if event.key in Hotkeys["Left"]:
                    if Options.AreDebugging:
                        print("pressed left")
                    KeyStatus["Left"] = True
                elif event.key in Hotkeys["Right"]:
                    if Options.AreDebugging:
                        print("pressed right")
                    KeyStatus["Right"] = True
                elif event.key in Hotkeys["Up"]:
                    KeyStatus["Up"] = True
                elif event.key in Hotkeys["Down"]:
                    KeyStatus["Down"] = True
                elif event.key in Hotkeys["Shift"]:
                    KeyStatus["Shift"] = True
                #else:
                    #if Options.AreDebugging:
                        #print(event)
            elif event.type == pygame.KEYUP:
                if event.key in Hotkeys["Quit"]:
                    quit()
                elif event.key in Hotkeys["Menu"]:
                    pass
                elif event.key in Hotkeys["Left"]:
                    if Options.AreDebugging == True:
                        print("released left")
                    KeyStatus["Left"] = False
                elif event.key in Hotkeys["Right"]:
                    if Options.AreDebugging:
                        print("released right")
                    KeyStatus["Right"] = False
                elif event.key in Hotkeys["Up"]:
                    KeyStatus["Up"] = False
                elif event.key in Hotkeys["Down"]:
                    KeyStatus["Down"] = False
                elif event.key in Hotkeys["Shift"]:
                    KeyStatus["Shift"] = False
                elif event.key in Hotkeys["Reset View"]:
                    camera.Reset()
                #else:
                    #if Options.AreDebugging:
                        #print(event)
            #else:
                #if Options.AreDebugging:
                    #print(event)
        self.EventQueue = list()
